<template>
  <div class="box">
    <nav-bra></nav-bra>
    <empty v-if="empty"></empty>
    <cart-list v-else></cart-list>
    <divider></divider>
    <list></list>
  </div>
</template>

<script>
import Empty from "../components/Cart/Empty.vue";
import NavBra from "../components/Cart/NavBra.vue";
import CartList from '../components/Cart/CartList.vue';


import { getCart } from "../apis/cart";
import List from '../components/Home/List.vue';
import Divider from '../components/Cart/divider.vue';

export default {
  components: { NavBra, Empty, CartList, List, Divider},
  // name: '我的Cart',

  data() {
    return {
      empty: true,
    };
  },

  mounted() {},
  created() {
    if(!localStorage.getItem("token")){
      this.$router.push("/login")
    }else{
      getCart({ userid: localStorage.getItem("userid") }).then((data) => {
        // console.log(data.data.code)
        if(data.data.code=="10020"){
            this.empty=true
        }else{
              this.empty = false;
              // console.log(this.empty)
        }
      });
    }
  
  },
  methods: {
  
  },
};
</script>

<style scoped>
div{
  /* position:absolute; */
  flex: 1;
}
</style>